﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;


using System.Xml.Linq;
using System.IO.IsolatedStorage;
using System.IO;
using System.Collections.ObjectModel;
using System.Windows.Media.Imaging;
using System.ComponentModel;
using Windows.Storage;

namespace ScannerDemo
{
    public partial class HomePagePivot : PhoneApplicationPage
    {
        XElement root;
        //delete_ids deleteing_id=new delete_ids();
        ObservableCollection<string> deleteing_id = new ObservableCollection<string>();
        ApplicationBarIconButton appBarIconBtnDlete = new ApplicationBarIconButton(new Uri("/icons/delete.png", UriKind.Relative));
        ApplicationBarIconButton appBarIconBtnFilter = new ApplicationBarIconButton(new Uri("/icons/filter.png", UriKind.Relative));
        ApplicationBarIconButton appBarIconBtnRelocation = new ApplicationBarIconButton(new Uri("/icons/scan icon.png", UriKind.Relative));
        bool isInDelAction=false;

        string check_scan = "True";
        string check_generate = "True";
        string check_all = "True";
        string check_http = "True";
        string check_vcard = "True";
        string check_txt = "True";

        bool isFromFilter = false;

       // ObservableCollection<date_item> item = new ObservableCollection<date_item>();

       
        private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
        {

        }

        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            try
            {
                #region C#生成ApplicationBar已经相关的Button和事件.
                ApplicationBar = new ApplicationBar();

                //ApplicationBarIconButton appBarIconBtnQR = new ApplicationBarIconButton(new Uri("/icons/appbar.refresh.rest.png", UriKind.Relative));
                appBarIconBtnDlete.Text = "删选";
                appBarIconBtnDlete.Click += new EventHandler(ApplicationBar_Delete_Click);
                //appBarIconBtnDlete.IsEnabled = false;
                //ApplicationBar.Buttons.Add(appBarIconBtnDlete);

                appBarIconBtnRelocation.Text = "扫描";
                appBarIconBtnRelocation.Click += new EventHandler(ApplicationBar_StartPage_Click);
                ApplicationBar.Buttons.Add(appBarIconBtnRelocation);

                appBarIconBtnFilter.Text = "筛选";
                appBarIconBtnFilter.Click += new EventHandler(ApplicationBar_Filter_Click);
                //appBarIconBtnFilter.IsEnabled = false;
                //ApplicationBar.Buttons.Add(appBarIconBtnFilter);



                ApplicationBar.IsVisible = true;
                isInDelAction = false;

                #endregion

            }
            catch (Exception ex)
            {
                //MessageBox.Show(ex.Message);
            }
           if (ApplicationBar != null)
            {
                ShowAppBar();
                //ShowHistory("True", "True", "True", "True", "True", "True");

            }
           
            //
           if ((NavigationContext.QueryString.Count > 0))
           {
               isFromFilter = true;
               string tempString = "";
               if ((NavigationContext.QueryString.Count == 1))
               {
                   NavigationContext.QueryString.TryGetValue("pivotIndex", out tempString);
                   if (tempString == "1")
                       homePagePivot.SelectedIndex = 1;
               }
               if (NavigationContext.QueryString.Count >= 2)
               {
                   NavigationContext.QueryString.TryGetValue("pivotIndex", out tempString);
                   if (tempString == "1")
                       homePagePivot.SelectedIndex = 1;

                   NavigationContext.QueryString.TryGetValue("text", out tempString);
                   NavigationContext.QueryString.TryGetValue("check_scan", out check_scan);
                   NavigationContext.QueryString.TryGetValue("check_generate", out check_generate);
                   NavigationContext.QueryString.TryGetValue("check_all", out check_all);
                   NavigationContext.QueryString.TryGetValue("check_http", out check_http);
                   NavigationContext.QueryString.TryGetValue("check_vcard", out check_vcard);
                   NavigationContext.QueryString.TryGetValue("check_txt", out check_txt);
                   //ShowHistory(check_scan, check_generate, check_all, check_http, check_vcard, check_txt);
                   NavigationContext.QueryString.Clear();
               }
           }
           else
           {
               isFromFilter = false;
               //ShowHistory("True", "True", "True", "True", "True", "True");
           }
           ShowHistory(check_scan, check_generate, check_all, check_http, check_vcard, check_txt);
        }



        private void ShowAppBar()
        {
            try
            {

                if (homePagePivot.SelectedIndex == 1)//history
                {
                    ApplicationBar.Buttons.Clear();
                    ApplicationBar.Buttons.Add(appBarIconBtnRelocation);
                    ApplicationBar.Buttons.Add(appBarIconBtnDlete);
                    ApplicationBar.Buttons.Add(appBarIconBtnFilter);

                    deleteing_id.Clear();
                }
                else
                {
                    ApplicationBar.Buttons.Clear();
                    ApplicationBar.Buttons.Add(appBarIconBtnRelocation);
                    //  ApplicationBar.Buttons.Remove(appBarIconBtnDlete);
                    // ApplicationBar.Buttons.Remove(appBarIconBtnFilter);
                }
            }
            catch { }
        }

        private void ApplicationBar_Filter_Click(object sender, EventArgs e)
        {
             //NavigationService.Navigate(new Uri("/select.xaml", UriKind.Relative));
            string uriString = @"/ScannerDemo;component/select.xaml?check_scan=" + check_scan + "&check_generate=" + check_generate
                    + "&check_all=" + check_all + "&check_http=" + check_http + "&check_vcard=" + check_vcard + "&check_txt=" + check_txt;
            NavigationService.Navigate(new Uri(uriString, UriKind.RelativeOrAbsolute));
        }

        private void ApplicationBar_Delete_Click(object sender, EventArgs e)
        {
            ApplicationBar = new ApplicationBar();

            ApplicationBar.Mode = ApplicationBarMode.Default;
            ApplicationBar.Opacity = 1.0;
            ApplicationBar.IsVisible = true;
            ApplicationBar.IsMenuEnabled = true;

            ApplicationBarIconButton button1 = new ApplicationBarIconButton();
            button1.IconUri = new Uri("/icons/delete.png", UriKind.Relative);
            button1.Text = "删除";
            ApplicationBar.Buttons.Add(button1);
            //date_result.IsHitTestVisible = true;
            isInDelAction = true;
            button1.Click += new EventHandler(button1_Click);
        }

        public HomePagePivot()
        {
            InitializeComponent();


            //ShowHistory("True","True","True","True","True","True");
        }

        public void ShowHistory(string check_scan,string check_generate,string check_all,string check_http,string check_vcard,string check_txt)
        {
            ObservableCollection<date_item> item = new ObservableCollection<date_item>();
          
            //item = new ObservableCollection<date_item>();;
            try
            {
                //date_result.IsHitTestVisible = false;
                
                using (var myFileStream = new IsolatedStorageFileStream("re.xml", FileMode.Open, IsolatedStorageFile.GetUserStoreForApplication()))
                using (var reader = new StreamReader(myFileStream))
                {
                    //result.Text = reader.ReadToEnd();
                    //string c = reader.ReadToEnd();
                    //string b = reader.ReadLine();
                    //MessageBox.Show(c);
                    int flag1 = 0;
                    try
                    {
                       // if (root==null)
                        root = XElement.Load(reader);

                        reader.Close();
                    }
                    catch
                    {

                        return;
                    }

                    XNode Node_result = root.FirstNode.NextNode;
                    XNode Node_result_last = root.LastNode;
                    //result.Text = node_result.Element("result_item").Element("type").Value;
                    while (flag1 == 0)
                    {
                        int flag2 = 0;
                        XElement node_result = XElement.Load(Node_result.CreateReader());
                        date_item item1 = new date_item { date = node_result.Element("date").Value };
                        //result.Text = node_result.Element("date").Value;
                        item1.results = new List<result>();
                        XNode Node_result_item = node_result.FirstNode.NextNode;
                        //result.Text = Node_result_item.ToString();
                        XNode Node_result_item_last = node_result.LastNode;
                        XElement node_result_item;
                        while (flag2 == 0)
                        {
                            node_result_item = XElement.Load(Node_result_item.CreateReader());
                            /*
                            string selectedLayer = "";
                            if (deleteing_id.Contains(node_result_item.Element("id").Value))
                            {
                                selectedLayer = "/icons/selected layer.png";
                            }
                             */

                            result a = new result(node_result_item.Element("type").Value, node_result_item.Element("min").Value, node_result_item.Element("text").Value, node_result_item.Element("id").Value, node_result_item.Element("generate_type").Value);
                            if (check_scan == "True" && check_generate == "True")
                            {
                                if (check_http == "True")
                                {
                                    if (a.type == "网址")
                                    {
                                        item1.results.Add(a);
                                    }
                                }
                                if (check_vcard == "True")
                                {
                                    if (a.type == "名片")
                                    {
                                        item1.results.Add(a);
                                    }
                                }
                                if (check_txt == "True")
                                {
                                    if (a.type == "文本")
                                    {
                                        string[] bs=a.text.Split('\n');
                                        a.text=bs[0];
                                        item1.results.Add(a);
                                    }
                                }
                            }
                            else if (check_scan == "True" && check_generate == "False")
                            {
                                if (a.generate_type == "1")
                                {
                                    if (check_http == "True")
                                    {
                                        if (a.type == "网址")
                                        {
                                            item1.results.Add(a);
                                        }
                                    }
                                    if (check_vcard == "True")
                                    {
                                        if (a.type == "名片")
                                        {
                                            item1.results.Add(a);
                                        }
                                    }
                                    if (check_txt == "True")
                                    {
                                        if (a.type == "文本")
                                        {
                                            string[] bs = a.text.Split('\n');
                                            a.text = bs[0];
                                            item1.results.Add(a);
                                        }
                                    }
                                }
                            }
                            else if (check_scan == "False" && check_generate == "True")
                            {
                                if (a.generate_type == "2")
                                {
                                    if (check_http == "True")
                                    {
                                        if (a.type == "网址")
                                        {
                                            item1.results.Add(a);
                                        }
                                    }
                                    if (check_vcard == "True")
                                    {
                                        if (a.type == "名片")
                                        {
                                            item1.results.Add(a);
                                        }
                                    }
                                    if (check_txt == "True")
                                    {
                                        if (a.type == "文本")
                                        {
                                            item1.results.Add(a);
                                        }
                                    }
                                }
                            }
                            if (Node_result_item == Node_result_item_last)
                            {
                                flag2 = 1;
                            }
                            else
                            {
                                Node_result_item = Node_result_item.NextNode;
                            }
                        }
                        //node_result_item = XElement.Load(Node_result_item.CreateReader());
                        //item1.results.Add(new result { type = node_result_item.Element("type").Value, min = node_result_item.Element("min").Value, text = node_result_item.Element("text").Value });
                        if(item1.results.Count>0)
                        {
                            item.Add(item1);
                        }
                        if (Node_result == Node_result_last)
                        {
                            flag1 = 1;
                        }
                        else
                        {
                            Node_result = Node_result.NextNode;
                        }
                    }
                    this.date_result.ItemsSource = item;
                    if ((item.Count == 0) && (isFromFilter))
                    {
                        MessageBox.Show("没有这样的历史记录！");
                        string uriString = @"/ScannerDemo;component/select.xaml?check_scan=" + check_scan + "&check_generate=" + check_generate
                    + "&check_all=" + check_all + "&check_http=" + check_http + "&check_vcard=" + check_vcard + "&check_txt=" + check_txt;
                        NavigationService.Navigate(new Uri(uriString, UriKind.RelativeOrAbsolute));
                        //NavigationService.Navigate(new Uri("/select.xaml", UriKind.Relative));
                    }
                }
            }
            catch
            {
                this.date_result.ItemsSource = item;
                //MessageBox.Show("没有历史记录");

            }
        }


        private void Button_Click_Text(object sender, RoutedEventArgs e)
        {
            string uriString = "/ScannerDemo;component/GenerateText.xaml";

            NavigationService.Navigate(new Uri(uriString, UriKind.RelativeOrAbsolute));
        }

        private void Button_Click_Url(object sender, RoutedEventArgs e)
        {
            string uriString = "/ScannerDemo;component/GenerateUrl.xaml";

            NavigationService.Navigate(new Uri(uriString, UriKind.RelativeOrAbsolute));
        }

        private void Button_Click_Vcard(object sender, RoutedEventArgs e)
        {
            string uriString = "/ScannerDemo;component/GenerateVcard.xaml";

            NavigationService.Navigate(new Uri(uriString, UriKind.RelativeOrAbsolute));
        }



        private void ApplicationBar_StartPage_Click(object sender, EventArgs e)
        {
            NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));
        }

        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            NavigationService.Navigate(new Uri("/choose_photo.xaml", UriKind.Relative));
        }

        //private void Button_Click_2(object sender, RoutedEventArgs e)
        //{
        //    NavigationService.Navigate(new Uri("/view_history.xaml", UriKind.Relative));
        //}
        private void ApplicationBarIconButton_Click_1(object sender, EventArgs e)
        {
            NavigationService.Navigate(new Uri("/select.xaml", UriKind.Relative));
        }


        private void delete_Click_2(object sender, EventArgs e)
        {
            ApplicationBar = new ApplicationBar();

            ApplicationBar.Mode = ApplicationBarMode.Default;
            ApplicationBar.Opacity = 1.0;
            ApplicationBar.IsVisible = true;
            ApplicationBar.IsMenuEnabled = true;

            ApplicationBarIconButton button1 = new ApplicationBarIconButton();
            button1.IconUri = new Uri("/Images/YourImage.png", UriKind.Relative);
            button1.Text = "删除";
            ApplicationBar.Buttons.Add(button1);
            button1.Click += new EventHandler(button1_Click);
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (deleteing_id.Count > 0)
            {
                if ((isInDelAction == true) && (MessageBox.Show("确定要删除吗？", "提示", MessageBoxButton.OKCancel) == MessageBoxResult.Cancel))
                    deleteing_id.Clear();
                // MessageBox.Show("删除成功!"); 
            }
            if (deleteing_id.Count > 0)
            {
                foreach (string i in deleteing_id)
                {
                    delete_xml_data(i);
                }
            }
            //NavigationService.Navigate(new Uri("/view_history.xaml", UriKind.Relative));
            //NavigationService.Navigate(new Uri("/HomePagePivot.xaml", UriKind.Relative));
            //reload history

            load_bar();
            /*
             check_scan = "True";
             check_generate = "True";
             check_all = "True";
             check_http = "True";
             check_vcard = "True";
             check_txt = "True";
             * */
            //ShowHistory("True", "True", "True", "True", "True", "True");
            ShowHistory(check_scan, check_generate, check_all, check_http, check_vcard, check_txt);
            isInDelAction = false;
        }

        private void load_bar()
        {
            try
            {
                #region C#生成ApplicationBar已经相关的Button和事件.
                ApplicationBar = new ApplicationBar();

                //ApplicationBarIconButton appBarIconBtnQR = new ApplicationBarIconButton(new Uri("/icons/appbar.refresh.rest.png", UriKind.Relative));


                appBarIconBtnRelocation.Text = "扫描";
                appBarIconBtnRelocation.Click += new EventHandler(ApplicationBar_StartPage_Click);
                ApplicationBar.Buttons.Add(appBarIconBtnRelocation);

                appBarIconBtnDlete.Text = "删选";
                appBarIconBtnDlete.Click += new EventHandler(ApplicationBar_Delete_Click);
                //appBarIconBtnDlete.IsEnabled = false;
                ApplicationBar.Buttons.Add(appBarIconBtnDlete);

                appBarIconBtnFilter.Text = "筛选";
                appBarIconBtnFilter.Click += new EventHandler(ApplicationBar_Filter_Click);
                //appBarIconBtnFilter.IsEnabled = false;
                ApplicationBar.Buttons.Add(appBarIconBtnFilter);



                ApplicationBar.IsVisible = true;
                //date_result.IsHitTestVisible = false;

                #endregion

            }
            catch (Exception ex)
            {
                //MessageBox.Show(ex.Message);
            }
        }

        private void delete_xml_data(string i)
        {
           // XElement root;
            int flag=0;
           // using (var myFileStream = new IsolatedStorageFileStream("re.xml", FileMode.Open, IsolatedStorageFile.GetUserStoreForApplication()))
           // using (var reader = new StreamReader(myFileStream))
           // {
               // root = XElement.Load(reader);
               // reader.Close();
               // myFileStream.Close();
                foreach (var item_result in root.Elements("result"))
                {
                    foreach (var item_result_item in item_result.Elements("result_item"))
                    {
                        if (item_result_item.Element("id").Value.ToString() == i)
                        {
                            if (item_result.Nodes().Count() == 2)
                            {
                                item_result.Remove();
                            }
                            else
                            {
                                item_result_item.Remove();
                                //MessageBox.Show(root.ToString());
                               
                            }
                        }
                    }
                }
                if (root.Nodes().Count() == 1)
                {
                    flag = 1;
                }
               

           // }
            using (var myFileStream = new IsolatedStorageFileStream("re.xml", FileMode.Create,FileAccess.Write, IsolatedStorageFile.GetUserStoreForApplication()))
            using (var writer = new StreamWriter(myFileStream))
            {
                root.Save(writer);
                writer.Close();
                myFileStream.Close();
            }
            if (flag == 1)
            {
                IsolatedStorageFile file = IsolatedStorageFile.GetUserStoreForApplication();
                if (file.FileExists("re.xml"))
                {
                    file.DeleteFile("re.xml");
                }
            }
            
        }

        private void OnSettingClicked(object sender, System.Windows.Input.GestureEventArgs e)
        {
              
        }

        private void ListBox_SelectionChanged_1(object sender, SelectionChangedEventArgs e)
        {
            //result.Text = "a";

            ListBox listBox = sender as ListBox;

            //deleteing_id.Clear();
            //var resultAdd=e.AddedItems[0] as result;
            //var resultDel = e.RemovedItems[0] as result;
            if (e.AddedItems.Count > 0)
            {
                var resultAdd = e.AddedItems[0] as result;
                if (!isInDelAction)
                {
                    if (resultAdd.type == "名片")
                        NavigateToVcar(resultAdd.total_text);
                    else
                    {
                        string uriString = @"/ScannerDemo;component/ScanResult.xaml?text=" + resultAdd.total_text;
                        App.PublicText = resultAdd.total_text;
                        NavigationService.Navigate(new Uri(uriString, UriKind.RelativeOrAbsolute));
                    }
                }
                else
                {
                    deleteing_id.Add(resultAdd.id);
                }
            }

            if (e.RemovedItems.Count>0)
                deleteing_id.Remove((e.RemovedItems[0] as result).id);
           // if (e.AddedItems.Count>0)
                //result re=e.AddedItems.[0];
            /*
            int j;
            for (j = 0; j < listBox.SelectedItems.Count;j++ )
            {
                var res = listBox.SelectedItems[j];
                
                result re = res as result;
                if (!isInDelAction)
                {
                    if (re.type == "名片")
                        NavigateToVcar(re.total_text);
                    else
                    {
                        string uriString = @"/ScannerDemo;component/ScanResult.xaml?text=" + re.total_text;
                        App.PublicText = re.total_text;

                        NavigationService.Navigate(new Uri(uriString, UriKind.RelativeOrAbsolute));
                    }
                }
                else
                {
                    //re.selectedLayer = "/icons/selected layer.png";
                    //var a=this.date_result.ItemsSource;
                    //if (deleteing_id.Contains(re.id))
                    //    deleteing_id.Remove(re.id);
                    //else
                       // deleteing_id.Add(re.id);
                }
            }
             * */
            /*
            ListBoxItem lbi2 = (ListBoxItem)(listBox.ItemContainerGenerator.ContainerFromItem(listBox.SelectedItems));

            //var g = this.date_result.ItemsSource.GetEnumerator();// = item;
            var g = item.GetEnumerator();
            date_item temp;
            while (g.MoveNext())
            {
                temp = (date_item)g.Current;
                
               
                for (j = 0; j < temp.results.Count; j++)
                {
                    if (deleteing_id.Contains(temp.results[j].id))
                        temp.results[j].selectedLayer = "/icons/selected layer.png";
                }

                
            }
             * */
            //date_result.UpdateLayout();
           // date_result.ItemsSource = null;
           // date_result.ItemsSource = item;
           // item.CollectionChanged+=item_CollectionChanged;
            

           // lbi2.Foreground = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.Blue);
            //ShowHistory(check_scan, check_generate, check_all, check_http, check_vcard, check_txt);
        }
        async public void NavigateToVcar(string text)
        {
            try
            {

                if (text.Contains("BEGIN:VCARD"))
                {
                    string fileName = "temp2open.vcf";
                    Vcard vcard = new Vcard();
                    await vcard.WriteFile(fileName, text);
                    DefaultLaunch(fileName);
                }
                else
                {


                }
            }
            catch { }

        }
        async void DefaultLaunch(string fileName)
        {

            // Path to the file in the app package to launch

            // string fileName = @"test.vcf";

            IStorageFolder applicationFolder = ApplicationData.Current.LocalFolder;
            IStorageFile storageFile = await applicationFolder.GetFileAsync(fileName);

            //var storageFile = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync(fileName);



            if (storageFile != null)
            {

                // Launch the retrieved file

                var success = await Windows.System.Launcher.LaunchFileAsync(storageFile);


            }

            else
            {

                // Could not find file

            }

        }

        private void HomePagePivot_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            //date_result.IsHitTestVisible = false;
            
            isInDelAction = false;
            //date_result.ItemTemplate. .SelectedItems.Clear();
            if (ApplicationBar != null)
            {
               ShowAppBar();
                
              // check_scan = "True";
               //check_generate = "True";
              // check_all = "True";
               //check_http = "True";
              // check_vcard = "True";
               //check_txt = "True";
                ShowHistory(check_scan, check_generate, check_all, check_http, check_vcard, check_txt);
               //ShowHistory("True", "True", "True", "True", "True", "True");
                

            }
        }

        //重写返回事件-退出程序
        protected override void OnBackKeyPress(CancelEventArgs e)
        {
            e.Cancel = true;

            Dispatcher.BeginInvoke(() =>
            {
                if (isInDelAction == true)
                {
                    if (MessageBox.Show("要取消删除吗？", "提示", MessageBoxButton.OKCancel) == MessageBoxResult.Cancel)
                        e.Cancel = true;
                    else
                    {
                        e.Cancel = false;
                        isInDelAction = false;
                        deleteing_id.Clear();
                        load_bar();
                        ShowHistory(check_scan, check_generate, check_all, check_http, check_vcard, check_txt);
                        //NavigationService.Navigate(new Uri("/HomePagePivot.xaml?pivotIndex=1", UriKind.Relative));
                    }
                }
                else
                {
                    e.Cancel = false;
                    NavigationService.Navigate(new Uri("/MainPage.xaml?pivotIndex=1", UriKind.Relative));
                }
                base.OnBackKeyPress(e);
            });

               
        }

        private void date_result_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {

        }


    }


    public class delete_ids
    {
        public List<string> ids { get; set; }
    }

    public class date_item
    {
        public string date { get; set; }
        public List<result> results { get; set; }
    }
    public class result
    {
        public string type { get; set; }
        public string min { get; set; }
        public string text { get; set; }
        public string image { get; set; }
        public string total_text { get; set; }
        public string id { get; set; }
        //public string selectedLayer { get; set; }
        public string generate_type { get; set; }
        public result(string a, string b, string c, string d,string e)
        {
            this.type = a;
            this.min = b;
            this.total_text = c;
            this.id = d;
           // this.selectedLayer = layer;
            this.generate_type = e;
            if (a == "名片")
            {
                try
                {
                    int i = c.IndexOf("FN:")+3;
                    // i = 26;
                    if (i == (-1+3))
                        i = c.IndexOf("N:", 20)+2;
                    int j = c.IndexOf("\n", i);
                    this.text = c.Substring(i, j - i);
                }
                catch
                {
                    this.text = c;
                }
            }
            else
            {
                if (c.Length > 20)
                {
                    this.text = c.Substring(0, 20);
                }
                else
                {
                    this.text = c;
                }
            }
            if (a == "网址")
            {
                this.image = "/icons/website_color.png";
            }
            else if (a == "名片")
            {
                this.image = "/icons/namecard_color.png";
            }
            else
            {
                this.image = "/icons/text_color.png";
            }
        }
    }




    
}